<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('project_invoices', function (Blueprint $table) {
            $table->id();
            // 关联工程项目，可根据实际情况调整关联字段类型
            $table->unsignedBigInteger('project_id')->default(0);
            $table->unsignedBigInteger('user_id')->default(0);
            $table->decimal('price',)->default(0);
            $table->decimal('tax_rate')->default(0)->comment('税率');
            $table->decimal('tax_price', 10, 2)->default(0)->comment('税金');
            $table->decimal('mix')->default(0)->comment('比率');
            // 甲方信息
            $table->string('name', 255)->default('/')->comment('甲方名称');
            $table->string('tax_id', 50)->nullable()->default('/')->comment('甲方税号');
            $table->string('address', 255)->nullable()->default('/')->comment('甲方地址');
            $table->string('mobile', 20)->nullable()->default('/')->comment('甲方联系电话');
            $table->string('bank', 255)->nullable()->default('/')->comment('甲方开户银行');
            $table->string('bank_number', 255)->nullable()->default('/')->comment('甲方开户好');
            $table->string('bank_account', 50)->nullable()->default('/')->comment('甲方银行账号');
            $table->string('email', 255)->nullable()->default('/')->comment('');
            $table->string('postal_code', 50)->nullable()->default('/')->comment('邮编');

            $table->string('b_name', 255)->default('/')->comment('乙方名称');
            $table->string('b_tax_id', 50)->nullable()->default('/')->comment('乙方税号');
            $table->string('b_address', 255)->nullable()->default('/')->comment('乙方地址');
            $table->string('b_mobile', 20)->nullable()->default('/')->comment('乙方联系电话');
            $table->string('b_bank', 255)->nullable()->default('/')->comment('乙方开户银行');
            $table->string('b_bank_number', 255)->nullable()->default('/')->comment('乙方开户好');
            $table->string('b_bank_account', 50)->nullable()->default('/')->comment('乙方银行账号');
            $table->string('b_email', 255)->nullable()->default('/')->comment('');
            $table->string('b_postal_code', 50)->nullable()->default('/')->comment('邮编');
            // 开票信息
            $table->decimal('invoice_amount', 10, 2)->default(0)->comment('开票金额');
            $table->string('invoice_type', 50)->nullable()->comment('发票类型，如增值税专用发票、普通发票');
            $table->string('invoice_content', 255)->nullable()->comment('开票内容，如工程款、服务费用等');
            $table->string('remarks')->nullable()->comment('');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('project_invoices');
    }
};
